<!DOCTYPE html>
<html lang="zh-CN">





<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/apple-touch-icon.png">
  <link rel="icon" type="image/png" href="/blog/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="兴趣使然的个人博客">
  <meta name="author" content="Ilirus">
  <meta name="keywords" content>
  <title>使用Vue-cli搭建Vue项目 - Ilirus</title>

  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css">


  <link rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css">
  <link rel="stylesheet" href="/blog/lib/hint/hint.min.css">

  
    <link rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/atom-one-light.min.css">
  

  


<!-- 主题依赖的图标库，不要自行修改 -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">

<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">

<link rel="stylesheet" href="/blog/css/main.css">

<!-- 自定义样式保持在最底部 -->


  <script src="/blog/js/utils.js"></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/blog/">&nbsp;<strong>Ilirus</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/blog/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2018-12-10 12:20">
      2018年12月10日 中午
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.2k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      16
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
            <article class="markdown-body">
              <h1 id="使用Vue-cli搭建Vue项目"><a href="#使用Vue-cli搭建Vue项目" class="headerlink" title="使用Vue-cli搭建Vue项目"></a>使用Vue-cli搭建Vue项目</h1><h2 id="安装Vue-cli"><a href="#安装Vue-cli" class="headerlink" title="安装Vue-cli"></a>安装Vue-cli</h2><p>在安装Vue-cli之前需要先安装<code>node</code>环境以及<code>npm</code>包管理工具</p>
<p>安装好之后可以通过以下命令查看版本<br><pre><code class="hljs batch">:: 查看node版本
node -v

:: 查看npm版本
npm -v</code></pre></p>
<p>全局安装Vue-cli<br><pre><code class="hljs batch">npm install @vue/cli -g
:: 或者
yarn global add @vue/cli</code></pre></p>
<p>安装后使用<code>vue --version</code>来查看版本</p>
<p>运行以下命令在<strong>当前</strong>文件夹下创建一个项目<br><pre><code class="hljs batch">:: 命令行创建项目
vue create &lt;projectName&gt;

:: 使用可视化项目创建工具
vue ui</code></pre></p>
<p>创建完成后，进入到刚才创建的文件夹下，运行<code>npm run serve</code>即可启动项目</p>
<a id="more"></a>
<h2 id="项目结构"><a href="#项目结构" class="headerlink" title="项目结构"></a>项目结构</h2><pre><code class="hljs batch">&lt;projectName&gt;
├─node_modules
├─public
│ └─index.html
├─src
│ ├─assets
│ ├─components
│ ├─App.vue
│ └─main.js
└package.json</code></pre>
<ul>
<li><code>package.json</code> 用于记录项目依赖的库</li>
<li><code>assets</code> 用于存放静态资源，比如图片</li>
<li><code>components</code> 用于存放组件</li>
<li><code>App.vue</code> 根组件</li>
<li><code>main.js</code> 项目入口脚本</li>
</ul>
<h2 id="写一个Hello-World"><a href="#写一个Hello-World" class="headerlink" title="写一个Hello World"></a>写一个Hello World</h2><p>写在vue文件中<br><pre><code class="hljs html"><span class="hljs-comment">&lt;!-- 模板: html结构 --&gt;</span>
<span class="hljs-comment">&lt;!-- template中有且只能有一个根元素 --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"app"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>&#123;&#123;msg&#125;&#125;<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-comment">&lt;!-- 行为: 逻辑处理 --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;
  <span class="hljs-attr">name</span>: <span class="hljs-string">'app'</span>,
  data() &#123;
    <span class="hljs-keyword">return</span> &#123;<span class="hljs-attr">msg</span>: <span class="hljs-string">'Hello World'</span>&#125;
  &#125;
&#125;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-comment">&lt;!-- 样式: 样式表 --&gt;</span>
<span class="hljs-comment">&lt;!-- 加入scope关键词代表样式仅作用于当前组件中 --&gt;</span>
<span class="hljs-comment">&lt;!-- &lt;style scope&gt;&lt;/style&gt; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
<span class="hljs-selector-id">#app</span> &#123;
  <span class="hljs-attribute">text-align</span>: center;
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#2c3e50</span>;
&#125;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span></code></pre></p>
<p>写在main.js中<br><pre><code class="hljs javascript"><span class="hljs-comment">// 引入Vue</span>
<span class="hljs-keyword">import</span> Vue <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>
<span class="hljs-comment">// 引入根组件</span>
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">'./App.vue'</span>

<span class="hljs-comment">// 阻止Vue在启动时生成生产提示</span>
Vue.config.productionTip = <span class="hljs-literal">false</span>

<span class="hljs-comment">// 实例化Vue对象</span>
<span class="hljs-keyword">new</span> Vue(&#123;
  <span class="hljs-attr">render</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">h</span>) </span>&#123; <span class="hljs-keyword">return</span> h(App) &#125;
&#125;).$mount(<span class="hljs-string">'#app'</span>)

<span class="hljs-comment">// 也可使用以下方式</span>
<span class="hljs-keyword">new</span> Vue(&#123;
  <span class="hljs-attr">el</span>: <span class="hljs-string">'#app'</span>,
  <span class="hljs-attr">template</span>: <span class="hljs-string">'&lt;App/&gt;'</span>,
  <span class="hljs-attr">components</span>: &#123; App &#125;
&#125;)</code></pre></p>
<h2 id="创建并使用自己的组件"><a href="#创建并使用自己的组件" class="headerlink" title="创建并使用自己的组件"></a>创建并使用自己的组件</h2><p>在/src/components目录下创建<code>.vue</code>文件，注册之后在<code>.vue</code>文件中可以使用<code>&lt;compName/&gt;</code>或<code>&lt;compName&gt;&lt;/compName&gt;</code>的形式来使用组件</p>
<h3 id="全局注册组件"><a href="#全局注册组件" class="headerlink" title="全局注册组件"></a>全局注册组件</h3><p>在<code>main.js</code>中注册组件<br><pre><code class="hljs javascript"><span class="hljs-comment">// 引入组件</span>
<span class="hljs-keyword">import</span> compName <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/compName'</span>

<span class="hljs-comment">// 全局注册组件</span>
Vue.component(<span class="hljs-string">"compName"</span>, compName)</code></pre></p>
<h3 id="局部注册组件"><a href="#局部注册组件" class="headerlink" title="局部注册组件"></a>局部注册组件</h3><p>在要注册组件的<code>.vue</code>文件中<br><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-comment">// 引入组件</span>
<span class="hljs-keyword">import</span> compName <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/compName.vue'</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;
  <span class="hljs-attr">name</span>: <span class="hljs-string">'app'</span>,
  data() &#123;
    <span class="hljs-keyword">return</span> &#123;<span class="hljs-attr">msg</span>: <span class="hljs-string">'Hello World'</span>&#125;
  &#125;,
  <span class="hljs-comment">//局部注册组件</span>
  <span class="hljs-attr">components</span>: &#123;
    <span class="hljs-string">'compName'</span>: compName
  &#125;
&#125;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></p>
<h2 id="组件间的传值-props"><a href="#组件间的传值-props" class="headerlink" title="组件间的传值(props)"></a>组件间的传值(props)</h2><h3 id="父组件向子组件传值"><a href="#父组件向子组件传值" class="headerlink" title="父组件向子组件传值"></a>父组件向子组件传值</h3><p>父组件中给子组件绑定属性值<br><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"app"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">compName</span> <span class="hljs-attr">v-bind:msg</span>=<span class="hljs-string">"msg"</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">import</span> HelloWorld <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/HelloWorld.vue'</span>

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;
  <span class="hljs-attr">name</span>: <span class="hljs-string">'app'</span>,
  data() &#123;
    <span class="hljs-keyword">return</span> &#123;
      <span class="hljs-attr">msg</span>: <span class="hljs-string">"Hello World"</span>
    &#125;
  &#125;,
  <span class="hljs-attr">components</span>: &#123;
    HelloWorld
  &#125;
&#125;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></p>
<p>在子组件中获取<br><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;
  <span class="hljs-attr">name</span>: <span class="hljs-string">'HelloWorld'</span>,
  <span class="hljs-attr">props</span>: &#123;
    <span class="hljs-attr">msg</span>: <span class="hljs-built_in">String</span>,
    <span class="hljs-attr">default</span>: <span class="hljs-string">'Def'</span>  <span class="hljs-comment">// 默认值</span>
  &#125;
&#125;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-comment">&lt;!-- 或者 --&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;
  <span class="hljs-attr">name</span>: <span class="hljs-string">'HelloWorld'</span>,
  <span class="hljs-attr">props</span>: &#123;
    <span class="hljs-attr">msg</span>: &#123;
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>  <span class="hljs-comment">//required 为true 表示这个参数必须被传入</span>
    &#125;
  &#125;
&#125;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></p>
<h3 id="子组件向父组件传值"><a href="#子组件向父组件传值" class="headerlink" title="子组件向父组件传值"></a>子组件向父组件传值</h3><p>子组件中注册事件<br><pre><code class="hljs javascript">methods:&#123;
  foo() &#123;
    <span class="hljs-keyword">this</span>.$emit(ctmEvent,trsValue)
  &#125;
&#125;</code></pre></p>
<p><code>ctmEvent</code>即为注册的事件名称<br><code>trsValue</code>即为向父组件传递的值</p>
<p>父组件中绑定事件<br><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">compName</span> <span class="hljs-attr">v-on:ctmEvent</span>=<span class="hljs-string">"fun($event)"</span> /&gt;</span></code></pre></p>
<p>父组件中绑定事件后，当子组件触发事件后，会执行对应的函数，使用<code>$event</code> 来获取到子组件传递过来的值</p>
<p>定义函数来处理子组件传递过来的值，这里的<code>para</code>对应的是<code>$event</code><br><pre><code class="hljs javascript">fun(para) &#123;
  <span class="hljs-keyword">this</span>.title = para
&#125;</code></pre></p>
<h2 id="组件的生命周期-钩子函数"><a href="#组件的生命周期-钩子函数" class="headerlink" title="组件的生命周期(钩子函数)"></a>组件的生命周期(钩子函数)</h2><pre><code class="hljs javascript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;
  <span class="hljs-attr">name</span>: <span class="hljs-string">'app'</span>,
  data() &#123; ... &#125;,
  <span class="hljs-attr">methods</span>: &#123; ... &#125;,

  <span class="hljs-comment">// 组件实例化之前</span>
  <span class="hljs-comment">// 数据观测(data observer)和event/watcher 事件配置之前被调用</span>
  beforeCreate() &#123;&#125;,

  <span class="hljs-comment">// 组件实例化完毕, 但页面还没显示</span>
  <span class="hljs-comment">// 实例创建完成后立即被调用, 数据观测(data observer)和event/watcher 已配置, $el属性不可见</span>
  created() &#123;&#125;,

  <span class="hljs-comment">// 组件挂载之前, 页面依然未显示, (但虚拟Dom 已经配置  (存疑))</span>
  <span class="hljs-comment">// 在挂载前被调用, 相关render 函数首次被调用</span>
  beforeMount() &#123;&#125;,

  <span class="hljs-comment">// 组件挂载后, 此方法执行完成后, 页面显示</span>
  <span class="hljs-comment">// el 被新创建的vm.$el替换并挂载到实例上之后调用</span>
  mounted() &#123;&#125;,

  <span class="hljs-comment">// 组件更新前调用(此时仍然可以访问到更新前的Dom)</span>
  beforeUpdate() &#123;&#125;,

  <span class="hljs-comment">// 组件更新后调用(Dom 更新后调用)</span>
  updated() &#123;&#125;,

  <span class="hljs-comment">// keep-alive 组件激活时调用</span>
  activated() &#123;&#125;,

  <span class="hljs-comment">// keep-alive 组件停用时调用</span>
  deactivated() &#123;&#125;

  <span class="hljs-comment">// 组件销毁前</span>
  beforeDestroy() &#123;&#125;,

  <span class="hljs-comment">// 组件销毁</span>
  destroyed() &#123;&#125;,

  <span class="hljs-comment">// 捕获来自子组件的错误时调用</span>
  <span class="hljs-comment">// 可以返回false 以阻止错误继续向上传播</span>
  errorCaptured(<span class="hljs-built_in">Error</span>, Component, InfoString) &#123;
    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>
  &#125;
&#125;</code></pre>
            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/blog/categories/Vue-js/">Vue.js</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/blog/tags/JavaScript/">JavaScript</a>
                    
                      <a class="hover-with-bg" href="/blog/tags/Vue-js/">Vue.js</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://zh.wikipedia.org/wiki/Wikipedia:CC_BY-SA_3.0%E5%8D%8F%E8%AE%AE%E6%96%87%E6%9C%AC" rel="nofollow noopener">CC BY-SA 3.0协议</a> 。转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/blog/2019/01/25/Vue-Router的安装与使用/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Vue Router的安装与使用</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/blog/2018/12/08/Kotlin学习笔记03/">
                        <span class="hidden-mobile">Kotlin学习笔记03</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
              <!-- Comments -->
              <div class="comments" id="comments">
                
                
  <div id="lv-container" data-id="city" data-uid="MTAyMC80NTMxNi8yMTgyOQ==">
    <script type="text/javascript">
      function loadLivere() {
        addScript('https://cdn-city.livere.com/js/embed.dist.js');
      }
      createObserver(loadLivere, 'lv-container');
    </script>
    <noscript>为正常使用来必力评论功能请允许 JavaScript 运行</noscript>
  </div>


              </div>
            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    

    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/debouncer.js" ></script>
<script  src="/blog/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/blog/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/blog/js/clipboard-use.js" ></script>







  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "使用Vue-cli搭建Vue项目&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/blog/js/local-search.js" ></script>
  <script>
    var path = "/blog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script type="text/javascript">
      //定义获取词语下标
      var a_idx = 0;
      jQuery(document).ready(function ($) {
        //点击body时触发事件
        $("body").click(function (e) {
          //需要显示的词语
          var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善");
          //设置词语给span标签
          var $i = $("<span/>").text(a[a_idx]);
          //下标等于原来下标+1  余 词语总数
          a_idx = (a_idx + 1) % a.length;
          //获取鼠标指针的位置，分别相对于文档的左和右边缘。
          //获取x和y的指针坐标
          var x = e.pageX, y = e.pageY;
          //在鼠标的指针的位置给$i定义的span标签添加css样式
          $i.css({
            "z-index": 999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": rand_color()
          });
          // 随机颜色
          function rand_color() {
            return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
          }
          //在body添加这个标签
          $("body").append($i);
          //animate() 方法执行 CSS 属性集的自定义动画。
          //该方法通过CSS样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的，这样就可以创建动画效果。
          //详情请看http://www.w3school.com.cn/jquery/effect_animate.asp
          $i.animate({
            //将原来的位置向上移动180
            "top": y - 180,
            "opacity": 0
            //1500动画的速度
          }, 1500, function () {
            //时间到了自动删除
            $i.remove();
          });
        });
      })
      ;
    </script>
  














<script src="/blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginModelPath":"assets/","model":{"jsonPath":"/blog/live2dw/assets/tororo.model.json"},"display":{"position":"left","width":300,"height":300},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
